package com.tosh;

import java.util.Collection;

/**
 * User: arsentyev
 * Date: 02.08.12
 */
final class Utils {
    private Utils() {/*empty*/}

    public static String capitalize(String s) {
        if(isNOE(s)) {
            return s;
        }
        char c1 = s.charAt(0);
        if(c1 < 97) {//97 - 122(a-z)  65 - 90(A-Z)
            return s;
        } else {
            char[] arr = s.toCharArray();
            arr[0] -= 32;
            return new String(arr);
        }
    }

    public static boolean isNOE(String s) {
        return s == null || s.isEmpty();
    }

    public static boolean isNOE(Collection c) {
        return c == null || c.isEmpty();
    }

    public static <T> boolean isNOE(T[] t) {
        return t == null || t.length == 0;
    }

    public static int parseInt(String in) {
        try {
            return Integer.parseInt(in);
        } catch (NumberFormatException ex) {
            return -1;
        }
    }
}